package com.libmessagecenter

import android.content.Context
import android.util.Log
import com.vivo.push.PushClient
import com.vivo.push.sdk.OpenClientPushMessageReceiver


class VivoPushMessageReceiver : OpenClientPushMessageReceiver() {
    companion object {
        const val TAG = "VivoPushMessageReceiver"

        val pushSDK = object : PushSDKInterface {
            override fun register(context: Context, appId: String?, appKey: String?) {
                Log.i(TAG, "vivo is support push: ${PushClient.getInstance(context).isSupport}")

                try {
                    PushClient.getInstance(context).initialize()

                    PushClient.getInstance(context).turnOnPush { state ->
                        Log.i(TAG, "turnOnPush state = $state")

                        if (state == 0 || state == 1) {
                            LibMessageCenter.instance.register(PushClient.getInstance(context).regId)
                        }
                    }
                } catch (e: Exception) {
                    Log.e(TAG, "vivo push initialize error $e")
                }
            }
        }
    }

    override fun onReceiveRegId(context: Context?, regId: String?) {
        Log.i(TAG, "onReceiveRegId $regId")
    }
}